*********************************************************************************
/*Create scatter plot for total cost by TPI Bin for Correspondence and In-Person*/
*********************************************************************************
clear all

* File paths
local datapath "${mvpf_audits}/data/" 
local graphpath "${graphpath}" 

* Version of fig to produce 
global version  ${version} // paper or slides

* Other formatting
if "${version}" == "slides" {
	global title "title(" ", size(vhuge))"
	global img wmf
	graph set window fontface "Arial"
	global title "title(" ", size(vhuge))"
	global axis_size "" //xsize(6.5) ysize(4)" // makes figure wider
}

else if "${version}" == "paper" {
	global title "title("")"
	global img pdf
	graph set window fontface "LMRoman10-Regular"
	global title " "
	global axis_size " " // makes figure wider
}

*********************************************************************
* No Change Rates - Scatterplot *
*********************************************************************
use "${mvpf_audits}/data/figures_rep/ap17.dta", clear

preserve

	* set y-axis label, title, and figure name
	local ylab = "No Change Rate"
	
	* xtitle
	if "${inc}"=="agi" global xtitle = "AGI percentile group"
	if "${inc}"=="tpi" global xtitle = "TPI percentile group"

	* Preferences 
	local symbsize small
	local textsize vsmall
	
	global xlab "xlabel(1 "0-5" 2 "5-10" 3 "10-15" 4 "15-20" 5 "20-25" 6 "25-30" 7 "30-35" 8 "35-40" 9 "40-45" 10 "45-50" 11 "50-55" 12 "55-60" 13 "60-65" 14 "65-70" 15 "70-75" 16 "75-80" 17 "80-85" 18 "85-90" 19 "90-95" 20 "95-99" 21 "99-99.9" 22 "99.9+", labsize(small) tl(.5) nogrid angle(45))"
	
	*** Subgroup figure
	local fig_name = "no_change_${inc}"

	tw  (scatter assessed0 tpi_pctl if inrange(tpi_pctl, 1, 22), ///
		mcolor(sea) msymbol(C) msize(`symbsize')) ///
		, ///
		yscale(r(0 1)) ///
		ytitle("No Change Rate") xtitle("${xtitle}")   ///
		///legend(order(1 2 )  lab(1 "Revenue") lab(2 "Total costs") ///
		///ring(0) pos(11) col(1) symxsize(*3.5) region(lcolor(gs11))) ///
		legend(off) ///
		${title} ///
		xscale(r(1 22))  ///
		${xlab} ylabel(0(0.2)1,nogrid) 
	graph export "`graphpath'/`fig_name'.pdf", replace
	
restore